import { useState, useEffect } from 'react';
import { Input } from 'antd';

const CustomInput = (props) => {
  const [text, setText] = useState();
  useEffect(() => {
    setText(props.defaultValue);
  }, []);

  const changeText = (e) => {
    setText(e.target.value);
    props.onChange(e.target.value); // 默认的传出是value
  };
  return (
    <div>
      <h1>
        {props.defaultValue}
        <Input style={{ width: '100px' }} value={text} onChange={changeText} />
      </h1>
    </div>
  );
};

export default CustomInput;
